import 'package:flutter_app/models/general_type.dart';
import 'package:scoped_model/scoped_model.dart';

class FilterBarModel extends Model {
  late List<GeneralType> _roomTypeList = [];
  late List<GeneralType> _orientedList = [];
  late List<GeneralType> _floorList = [];

  final Set<String> _selectedIdList = <String>{};

  Map<String, List<GeneralType>> get dataList {
    var res = <String, List<GeneralType>>{};
    res["roomTypeList"] = _roomTypeList;
    res["orientedList"] = _orientedList;
    res["floorList"] = _floorList;

    return res;
  }

  set dataList(Map<String, List<GeneralType>> data) {
    _roomTypeList = data['roomTypeList']!;
    _orientedList = data['orientedList']!;
    _floorList = data['floorList']!;
    notifyListeners();
  }

  Set<String> get selectedIdList {
    return _selectedIdList;
  }

// 选择item时传进来的ID，如果有则删除否则加进去
  selectedToggleItem(String data) {
    if (_selectedIdList.contains(data)) {
      _selectedIdList.remove(data);
    } else {
      _selectedIdList.add(data);
    }
    notifyListeners();
  }
}
